﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<Style x:Key="ComboBoxAuthorStyle" TargetType="{x:Type ComboBox}">
		<Setter Property="SnapsToDevicePixels" Value="true"/>
		<Setter Property="Template" Value="{DynamicResource ComboBoxAuthorControlTemplate}"/>
		<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
		<Setter Property="ItemContainerStyle" Value="{DynamicResource ComboBoxItemStyle}"/>
	</Style>
	<ControlTemplate x:Key="ComboBoxAuthorControlTemplate" TargetType="{x:Type ComboBox}">
		<Grid>
			<!-- The ToggleButton is databound to the ComboBox itself to toggle IsDropDownOpen -->
			<ToggleButton Grid.Column="2" Template="{DynamicResource ComboBoxAuthorToggleButtonControlTemplate}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
			<!-- The Popup shows the list of items in the ComboBox. IsOpen is databound to IsDropDownOpen which is toggled via the ComboBoxToggleButton -->
			<Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
				<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
					<Border x:Name="DropDownBorder" Background="{DynamicResource BrushControlBackgroundLight}" BorderBrush="{DynamicResource ImpassiveColor4}" BorderThickness="1" CornerRadius="0,0,3,3"/>
					<ScrollViewer Margin="4,6,4,6" Style="{DynamicResource ComboBoxScrollViewerStyle}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
							
						<!-- The StackPanel is used to display the children by setting IsItemsHost to be True -->
						<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
								
					</ScrollViewer>
				</Grid>
			</Popup>
			<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Path=Hero.Author}" TextWrapping="Wrap" x:Name="textBlock" Margin="3,3,0,3"/>
		</Grid>
		<ControlTemplate.Triggers>						
			<!-- This forces the DropDown to have a minimum size if it is empty -->
			<Trigger Property="HasItems" Value="false">
				<Setter Property="MinHeight" Value="95" TargetName="DropDownBorder"/>
			</Trigger>
			<Trigger Property="IsEnabled" Value="false">
				<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
			</Trigger>
			<Trigger Property="IsGrouping" Value="true">
				<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
			</Trigger>
			<Trigger Property="AllowsTransparency" SourceName="Popup" Value="true">
				<Setter Property="CornerRadius" Value="4" TargetName="DropDownBorder"/>
				<Setter Property="Margin" Value="0,2,0,0" TargetName="DropDownBorder"/>
			</Trigger>
			<Trigger Property="IsEditable" Value="true">
				<Setter Property="IsTabStop" Value="false"/>
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
	<ControlTemplate x:Key="ComboBoxAuthorToggleButtonControlTemplate" TargetType="{x:Type ToggleButton}">
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition/>
				<ColumnDefinition Width="20"/>
			</Grid.ColumnDefinitions>
			<Border HorizontalAlignment="Stretch" Width="Auto" BorderBrush="{DynamicResource ImpassiveColor4}" Background="{DynamicResource BrushControlBackgroundLight}" BorderThickness="1,1,0,1" CornerRadius="3,0,0,3"/>
			<Grid Grid.Column="1">
				<Grid.RowDefinitions>
					<RowDefinition Height="0.514*"/>
					<RowDefinition Height="0.486*"/>
				</Grid.RowDefinitions>
				<Border BorderBrush="{DynamicResource ImpassiveColor4}" Grid.RowSpan="2" CornerRadius="0,3,3,0" BorderThickness="{DynamicResource ThicknessSize_1}" x:Name="border">
					<Border.Background>
						<LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
							<GradientStop Color="#FFA7BAA0" Offset="0"/>
							<GradientStop Color="#FFD0DECB" Offset="1"/>
						</LinearGradientBrush>
					</Border.Background>
				</Border>
				<Border Grid.RowSpan="1" BorderBrush="{DynamicResource ImpassiveColor4}" BorderThickness="1,1,1,0" Background="#33FFFFFF" CornerRadius="0,3,0,0"/>
			</Grid>
			<Path Grid.Column="1" HorizontalAlignment="Center" x:Name="Arrow" VerticalAlignment="Center" Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z"/>
		</Grid>
		<ControlTemplate.Triggers>
			<Trigger Property="IsMouseOver" Value="True">
				<Setter Property="Background" TargetName="border" Value="{DynamicResource BrushControlBackgroundLightFocused}"/>
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
	<!-- Resource dictionary entries should be defined here. -->
</ResourceDictionary>